<template>
  <div>
    <h1>孙组件</h1>
    <h2>车：{{ car }}，钱：{{ money }}</h2>
    <button @click="changeMoney">用根组件的钱</button>
  </div>
</template>

<script setup lang="ts">
import { inject, Ref } from 'vue';

const money = inject<Ref<number>>('money');
const car = inject<Ref<string>>('car');
const changeMoney = () => {
  if (money) {
    console.log(money.value);

    money.value -= 100;
  }
};
</script>
